/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package g5.page;

import g5.fw.HBox;
import g5.fw.IPage;
import g5.fw.ISection;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 *
 * @author hue
 */
public class Page implements IPage {
    private ArrayList<HBox<ISection>> hBoxes;

    @Override
    public ArrayList<HBox<ISection>> getHBoxes() {
        if(hBoxes == null) {
            hBoxes = new ArrayList();
        }
        return hBoxes;
    }

    @Override
    public JSONObject toJSON() throws JSONException {
        JSONObject jsObj = new JSONObject();
        
        JSONArray jsBoxes = new JSONArray();
        for(HBox box : hBoxes) {
            jsBoxes.put(box.toJSON());
        }
        jsObj.put("hBoxes", jsBoxes);
        
        return jsObj;
    }
}
